import 'package:flutter/material.dart';
import 'package:atten_sys/entity/Entity.dart';

class SelfInfo extends StatefulWidget {
  final User user;

  SelfInfo({Key key, @required this.user}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _SelfInfoState();
  }
}

class _SelfInfoState extends State<SelfInfo> {
  Widget buildInfoTextField(String label, String value, Icon icon) {
    return TextFormField(
      textAlign: TextAlign.center,
      enabled: false,
      decoration: InputDecoration(
          border: OutlineInputBorder(),
          prefixIcon: icon,
          labelText: label,
          labelStyle: TextStyle(
              fontSize: 18, fontWeight: FontWeight.w500, color: Colors.blueAccent)),
      initialValue: value,
      style: TextStyle(
          fontSize: 20, fontWeight: FontWeight.w500, color: Colors.black54),
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    double h = 30;
    return Form(
      child: new ListView(
        padding: EdgeInsets.symmetric(horizontal: 20),
        children: <Widget>[
          SizedBox(
            height: 50,
          ),
          buildInfoTextField('工号', widget.user.jobNumber, Icon(Icons.contacts)),
          SizedBox(
            height: h,
          ),
          buildInfoTextField('姓名', widget.user.username, Icon(Icons.person)),
          SizedBox(
            height: h,
          ),
          buildInfoTextField(
              '性别', widget.user.sex ? '男' : '女', Icon(Icons.insert_link)),
          SizedBox(
            height: h,
          ),
          buildInfoTextField(
              '所属单位', widget.user.unit.unitName, Icon(Icons.art_track))
        ],
      ),
    );
  }
}
